'use strict';

var core = require('@tauri-apps/api/core');
var event = require('@tauri-apps/api/event');

async function install(path) {
    return await core.invoke('plugin:install|install', {
        payload: {
            path,
        },
    }).then();
}
async function download(url, path, callback) {
    event.listen('/file/download', async (event) => {
        const { progressTotal, total } = event.payload;
        callback({ progressTotal: progressTotal, total: total });
    });
    return await core.invoke('plugin:install|download', {
        payload: {
            url, path
        }
    });
}

exports.download = download;
exports.install = install;
